package com.ruoyi.web.controller.operation;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GwPlatformServiceOrder;
import com.ruoyi.system.service.IGwPlatformServiceOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台服务订单Controller
 * 
 * @author ruoyi
 * @date 2025-05-09
 */
@Api(description = "平台运营管理-平台服务订单")
@RestController
@RequestMapping("/system/platformServiceOrder")
public class GwPlatformServiceOrderController extends BaseController
{
    @Autowired
    private IGwPlatformServiceOrderService gwPlatformServiceOrderService;

    /**
     * 查询平台服务订单列表
     */
    @ApiOperation("查询平台服务订单列表-分页")
    @GetMapping("/list")
    public TableDataInfo list(GwPlatformServiceOrder gwPlatformServiceOrder)
    {
        startPage();
        List<GwPlatformServiceOrder> list = gwPlatformServiceOrderService.selectGwPlatformServiceOrderList(gwPlatformServiceOrder);
        return getDataTable(list);
    }

    /**
     * 查询当前登录用户企业服务订单列表
     */
    @ApiOperation("查询当前登录用户企业服务订单列表")
    @GetMapping("/myEnterpriseList")
    public TableDataInfo myEnterpriseList(GwPlatformServiceOrder gwPlatformServiceOrder)
    {
        startPage();
        List<GwPlatformServiceOrder> list = gwPlatformServiceOrderService.myEnterpriseList(gwPlatformServiceOrder);
        return getDataTable(list);
    }

    /**
     * 导出平台服务订单列表
     */
//    @PreAuthorize("@ss.hasPermi('system:platformServiceOrder:export')")
    @Log(title = "平台服务订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GwPlatformServiceOrder gwPlatformServiceOrder)
    {
        List<GwPlatformServiceOrder> list = gwPlatformServiceOrderService.selectGwPlatformServiceOrderList(gwPlatformServiceOrder);
        ExcelUtil<GwPlatformServiceOrder> util = new ExcelUtil<GwPlatformServiceOrder>(GwPlatformServiceOrder.class);
        util.exportExcel(response, list, "平台服务订单数据");
    }

    /**
     * 获取平台服务订单详细信息
     */
    @ApiOperation("获取平台服务订单详细信息")
//    @PreAuthorize("@ss.hasPermi('system:platformServiceOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(gwPlatformServiceOrderService.selectGwPlatformServiceOrderById(id));
    }

    /**
     * 新增平台服务订单
     */
    @ApiOperation("新增平台服务订单")
//    @PreAuthorize("@ss.hasPermi('system:platformServiceOrder:add')")
    @Log(title = "平台服务订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GwPlatformServiceOrder gwPlatformServiceOrder)
    {
        return toAjax(gwPlatformServiceOrderService.insertGwPlatformServiceOrder(gwPlatformServiceOrder));
    }

    /**
     * 修改平台服务订单
     */
    @ApiOperation("修改平台服务订单")
//    @PreAuthorize("@ss.hasPermi('system:platformServiceOrder:edit')")
    @Log(title = "平台服务订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GwPlatformServiceOrder gwPlatformServiceOrder)
    {
        return toAjax(gwPlatformServiceOrderService.updateGwPlatformServiceOrder(gwPlatformServiceOrder));
    }

    /**
     * 删除平台服务订单
     */
    @ApiOperation("删除平台服务订单")
//    @PreAuthorize("@ss.hasPermi('system:platformServiceOrder:remove')")
    @Log(title = "平台服务订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(gwPlatformServiceOrderService.deleteGwPlatformServiceOrderByIds(ids));
    }

    @ApiOperation("取消订单")
    @Log(title = "平台服务订单", businessType = BusinessType.INSERT)
    @PostMapping("/cancelOrder")
    public AjaxResult cancelOrder(@RequestBody GwPlatformServiceOrder gwPlatformServiceOrder)
    {
        return toAjax(gwPlatformServiceOrderService.cancelOrder(gwPlatformServiceOrder));
    }

    @ApiOperation("PC端扫码支付订单")
    @Log(title = "平台服务订单", businessType = BusinessType.INSERT)
    @PostMapping("/payOrder")
    public AjaxResult payOrder(@RequestBody GwPlatformServiceOrder gwPlatformServiceOrder)
    {

        return gwPlatformServiceOrderService.payOrder(gwPlatformServiceOrder);
    }

    @ApiOperation("微信小程序支付订单")
    @Log(title = "平台服务订单", businessType = BusinessType.INSERT)
    @PostMapping("/applet/payOrder")
    public AjaxResult appletPayOrder(@RequestBody GwPlatformServiceOrder gwPlatformServiceOrder)
    {

        return gwPlatformServiceOrderService.appletPayOrder(gwPlatformServiceOrder);
    }

    @ApiOperation("微信小程序统计服务订单")
    @Log(title = "微信小程序统计服务订单", businessType = BusinessType.INSERT)
    @GetMapping("/applet/statisticsServiceOrder")
    public AjaxResult statisticsServiceOrder()
    {
        return gwPlatformServiceOrderService.statisticsServiceOrder();
    }
}
